	function swakOTSPrevious(otswindow) {
		//alert('swakOTSPrevious ' + otswindow);
		if (otswindow == null) return;
		var otslist = otswindow.opener.swakOTSList;
	//							alert('swakOTSPrevious otswindow.opener.content.document ' + otswindow.opener.swakOTSList);
		if (otslist == null) return;
	//							alert('otslist len ' + otslist.length);
		
		//var odoct = otswindow.document.getElementById('liveObjectContainer');
		//alert('odoct ' + odoct.innerHTML);
		
		if (otswindow.opener.swakOTSListIndex == 0) {
			return;
		}
		var pindex = otswindow.opener.swakOTSListIndex - 1;
		if (pindex < 0) {
			return;
		}
//		alert(otswindow.opener.swakOTSListIndex + ',swakOTSListIndex pindex ' +pindex);
		var oro = otslist[pindex];
		if (oro == null) return;
		var odoc = otswindow.document.getElementById('liveObjectContainer');
		odoc.innerHTML = oro.innerHTML;
		otswindow.opener.swakOTSListIndex = pindex;
		var pb = otswindow.document.getElementById('swakotsprevious');
		var nb = otswindow.document.getElementById('swakotsnext');
		if (pindex == 0) {
			//pb.setAttribute('disabled','true');
			pb.disabled=true;
		}
		else {
			//pb.setAttribute('disabled','false');
			pb.disabled=false;
		}
		if (pindex == otslist.length-1 || otslist.length < 2) {
			//nb.setAttribute('disabled','true');
			nb.disabled=true;
		}
		else {
			//nb.setAttribute('disabled','false');
			nb.disabled=false;
		}		
	}
	
	function swakOTSNext(otswindow) {
		if (otswindow == null) return;
		var otslist = otswindow.opener.swakOTSList;
		
		if (otslist == null) return;
//		alert('otslist len ' + otslist.length);
		var nindex = otswindow.opener.swakOTSListIndex + 1;
		var maxnext = otslist.length -1;
		
		if (nindex > maxnext) {
			return;
		}
//		alert(otswindow.opener.swakOTSListIndex + ',swakOTSListIndex nindex ' +nindex);
		var oro = otslist[nindex];
		if (oro == null) return;
		var odoc = otswindow.document.getElementById('liveObjectContainer');
		odoc.innerHTML = oro.innerHTML;
		otswindow.opener.swakOTSListIndex = nindex;
		var nb = otswindow.document.getElementById('swakotsnext');
		var pb = otswindow.document.getElementById('swakotsprevious');
		//alert('nb ' + nb);
		if (nindex == maxnext) {
			//nb.setAttribute('disabled','true');
			nb.disabled=true;
		}
		else {
			nb.setAttribute('disabled','false');
			nb.disabled=false;
		}
		if (nindex == 0) {
			//pb.setAttribute('disabled','true');
			pb.disabled=true;
		}
		else {
			//pb.setAttribute('disabled','false');
			pb.disabled=false;
		}
	}
	
	function swakOTSGraphUserPickToggle(otswindow) {
		if (otswindow == null) return;
		var cb = otswindow.document.getElementById('swakotsuserpick');
		if (cb == null) return;
		
		var usercells = swakOTSgetElementsByClassName('swakotsusercell',otswindow.document,otswindow.document,otswindow);
	//	alert(usercells);
		
			for (var i=0;i<usercells.length;i++) {
				if (cb.checked == false) {
					usercells[i].style.display="none"; 
				}
				else {
					usercells[i].style.display=""; 
				}
			}
			
		
	}
	
	function swakOTSClearSession(otswindow) {
		if (otswindow == null || otswindow.opener == null) return;
		var result = confirm("Clear current Outwit session data?");
		if (result) {
			otswindow.opener.swakClearOTSSessionResults();
		}
	}
	
	
	
	
	function swakOTSgetElementsByClassName(className,parent,doc,pWindow) {
		var q = ".//*[contains(concat(' ', @class, ' '), ' " + className + " ')]";
		return swakOTSgetElementsByXPath(q,parent,doc,pWindow);
	}
	
	
	
	function swakOTSgetElementsByXPath(expression,parent,ownerNode,pWindow) {
		try {
			if (ownerNode == null) ownerNode = content.document; 
			var results = [];
			var query = ownerNode.evaluate(expression, parent || pWindow.document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
			for (var i = 0, length = query.snapshotLength; i < length; i++)
			results.push(query.snapshotItem(i));
			return results;
		}
		 catch(x) {
		 	alert(x);
		}
	}
	